package com.ios.palette.utils;

import java.io.File;
import java.io.IOException;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

import org.springframework.web.multipart.MultipartFile;

public class Upload {
	public String uploadAndGetPath(MultipartFile file,HttpServletRequest request){
		ServletContext ctx=request.getSession().getServletContext();
		String filepath=ctx.getRealPath("/upload");
		try {
			file.transferTo(new File(filepath,file.getOriginalFilename()));
		} catch (IllegalStateException | IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return filepath;
	}
}
